import request from '@/utils/request'
import type { Exam, PageResponse, ExamStatus } from '@/types'

export const examApi = {
  getExams: (params: {
    page?: number
    size?: number
    query?: string
    status?: ExamStatus
    subjectId?: number
  }) => request.get<PageResponse<Exam>>('/exams', { params }),
  
  getExam: (id: number) => 
    request.get<Exam>(`/exams/${id}`),
  
  createExam: (exam: Exam) => 
    request.post<Exam>('/exams', exam),
  
  updateExam: (id: number, exam: Exam) => 
    request.put<Exam>(`/exams/${id}`, exam),
  
  deleteExam: (id: number) => 
    request.delete(`/exams/${id}`),
  
  publishExam: (id: number) => 
    request.post<Exam>(`/exams/${id}/publish`),
  
  archiveExam: (id: number) => 
    request.post<Exam>(`/exams/${id}/archive`)
}